package com.example.demo.entity.vo;

import com.example.demo.entity.pojo.Card;
import com.example.demo.entity.pojo.CostRecord;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.text.SimpleDateFormat;
import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class CostRecordVo {
    private int id;
    private int cardNumber;
    private double price;
    private String time;
    private String type;


    public CostRecordVo(CostRecord costRecord, Card card) {
        SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss" );
        this.cardNumber = card.getNumber();
        this.price = costRecord.getPrice();
        this.time = sdf.format(costRecord.getTime());
        if (costRecord.getType() == 0){
            this.type = "充值";
        }
        if (costRecord.getType() == 1){
            this.type = "借书消费";
        }
        if (costRecord.getType() == 2){
            this.type = "逾期归还消费";
        }
    }

}
